package gov.child.dao;

import gov.child.dao.exception.EntityDeleteException;
import gov.child.dao.exception.EntityQueryException;
import gov.child.dao.exception.EntitySaveException;
import gov.child.dao.exception.EntityUpdateException;
import gov.child.entities.po.EConsult;
import gov.child.entities.po.EDepartment;
import gov.child.entities.po.EUser;
import gov.child.entities.vo.Page;

import java.util.List;

/**
 * The interface Consult dao. --finish
 *
 * @author fzh
 * @since 2017 /9/10
 */
public interface ConsultDao extends Pageable{
    /**
     * 根据ID查询
     *
     * @param id the id
     * @return the by id
     * @throws EntityQueryException the entity query exception
     */
    EConsult findById(Integer id) throws EntityQueryException;

    /**
     * 查询所有咨询条目
     *
     * @return the all
     * @throws EntityQueryException the entity query exception
     */
    default List findAll() throws EntityQueryException {
        return findAll(Page.singlePage());
    }

    ;

    /**
     * 查询所有咨询条目（分页）
     *
     * @param page the page
     * @return the all
     * @throws EntityQueryException the entity query exception
     */
    List findAll(Page page) throws EntityQueryException;

    /**
     * 根据部门查询咨询条目
     *
     * @param department the department
     * @return the by department
     * @throws EntityQueryException the entity query exception
     */
    default List findByDepartment(EDepartment department) throws EntityQueryException {
        return findByDepartment(department, Page.singlePage());
    }

    ;

    /**
     * 根据部门查询咨询条目（分页）
     *
     * @param department the department
     * @param page       the page
     * @return the by department
     * @throws EntityQueryException the entity query exception
     */
    default List findByDepartment(EDepartment department, Page page) throws EntityQueryException {
        return findByDepartmentId(department.getId(), page);
    }

    default List findByDepartmentId(Integer departmentId) throws EntityQueryException {
        return findByDepartmentId(departmentId, Page.singlePage());
    }

    List findByDepartmentId(Integer departmentId, Page page) throws EntityQueryException;

    /**
     * 根据用户查询咨询条目
     *
     * @param user the user
     * @return the by user
     * @throws EntityQueryException the entity query exception
     */
    default List findByUser(EUser user) throws EntityQueryException {
        return findByUserId(user.getId(), Page.singlePage());
    }

    /**
     * 根据用户查询咨询条目（分页）
     *
     * @param user the user
     * @param page the page
     * @return the by user
     * @throws EntityQueryException the entity query exception
     */
    default List findByUser(EUser user, Page page) throws EntityQueryException {
        return findByUserId(user.getId(), page);
    }

    default List findByUserId(Integer userId) throws EntityQueryException {
        return findByUserId(userId, Page.singlePage());
    }

    List findByUserId(Integer userId, Page page) throws EntityQueryException;

    /**
     * 保存
     *
     * @param consult the consult
     * @throws EntitySaveException the entity save exception
     */
    void save(EConsult consult) throws EntitySaveException;

    /**
     * 删除
     *
     * @param consult the consult
     * @throws EntityDeleteException the entity delete exception
     */
    void delete(EConsult consult) throws EntityDeleteException;

    /**
     * 更新
     *
     * @param consult the consult
     * @throws EntityUpdateException the entity update exception
     */
    void update(EConsult consult) throws EntityUpdateException;
}
